package com.example.zx.theline.lyjh.pub;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.zx.theline.R;

import java.util.List;

import GsonBean.ShyjhxqBean;
import app.MyApplication;
import base.BaseActivity;


/**
 * 计划审核查看月计划  没有操作按钮 只能查看
 * */
public class JhshReadActivity extends BaseActivity implements View.OnClickListener {

    public static GsonBean.ShyjhxqBean ZsyjhxxShBean;
    //标题
    private TextView centerTextView;
    //计划内容
    private TextView lb, yf, ydbh, kssj, xm, dd, hb, lc, xmmc, sgnr, sgjx, blfh;
    // 相关单位
    private TextView sgdw, sgdwfzr, jldw, jldwfzr, jsdw, cwzd, sbgldw, qtdw, shcs, xmzgbm;
    // 按钮
    private TextView tv_cancel;
    private TextView rightTextView, leftTextView;
    private LinearLayout blfh_layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jhsh_read);
        InitView();
        InitData();
        InitListen();
    }

    @Override
    protected void InitView() {

        centerTextView = (TextView) findViewById(R.id.centerTextView);
        centerTextView.setText("月计划详情");

        lb = (TextView) findViewById(R.id.lb);
        yf = (TextView) findViewById(R.id.yf);
        ydbh = (TextView) findViewById(R.id.ydbh);
        kssj = (TextView) findViewById(R.id.kssj);
        xm = (TextView) findViewById(R.id.xm);
        dd = (TextView) findViewById(R.id.dd);
        hb = (TextView) findViewById(R.id.hb);
        lc = (TextView) findViewById(R.id.lc);
        xmmc = (TextView) findViewById(R.id.xmmc);
        sgnr = (TextView) findViewById(R.id.sgnr);
        sgjx = (TextView) findViewById(R.id.sgjx);
        blfh = (TextView) findViewById(R.id.blfh);
        blfh_layout = (LinearLayout) findViewById(R.id.blfh_layout);

        sgdw = (TextView) findViewById(R.id.sgdw);
        sgdwfzr = (TextView) findViewById(R.id.sgdwfzr);
        jldw = (TextView) findViewById(R.id.jldw);
        jldwfzr = (TextView) findViewById(R.id.jldwfzr);
        jsdw = (TextView) findViewById(R.id.jsdw);
        cwzd = (TextView) findViewById(R.id.cwzd);
        sbgldw = (TextView) findViewById(R.id.sbgldw);
        qtdw = (TextView) findViewById(R.id.qtdw);
        shcs = (TextView) findViewById(R.id.shcs);
        xmzgbm = (TextView) findViewById(R.id.xmzgbm);

        tv_cancel = (TextView) findViewById(R.id.tv_cancel);

        leftTextView = (TextView) findViewById(R.id.leftTextView);
        rightTextView = (TextView) findViewById(R.id.rightTextView);
    }


    @Override
    protected void InitData() {
        rightTextView.setVisibility(View.GONE);

        if (ZsyjhxxShBean == null) {
            MyApplication.ShowWaitDialog(this);
            MyApplication.setWaitDialogMsg("数据错误");
        } else {
            lb.setText(ZsyjhxxShBean.getInfo().getLb());
            yf.setText(ZsyjhxxShBean.getInfo().getSgny());
            ydbh.setText(ZsyjhxxShBean.getInfo().getBh());

            //日期时间为sgrqList内容拼接
            List<ShyjhxqBean.InfoBean.SgrqListBean> list=ZsyjhxxShBean.getInfo().getSgrqList();
            String s="";
            for(int i=0;i<list.size();i++){
                s+=list.get(i).getSgrqks()+" "+list.get(i).getSgsjks()+"至"+list.get(i).getSgrqjs()+" "+list.get(i).getSgsjjs();
                if(i+1<list.size()){
                    s+="，";
                }
            }
            kssj.setText(s);
            xm.setText(ZsyjhxxShBean.getInfo().getXlxbList().get(0).getXlmc());
            dd.setText(ZsyjhxxShBean.getInfo().getXlxbList().get(0).getSgdd());
            hb.setText(ZsyjhxxShBean.getInfo().getXlxbList().get(0).getXbmc());
            lc.setText(ZsyjhxxShBean.getInfo().getXlxbList().get(0).getLic());
            xmmc.setText(ZsyjhxxShBean.getInfo().getXmmc());
            sgnr.setText(ZsyjhxxShBean.getInfo().getNrmc());
            sgjx.setText(ZsyjhxxShBean.getInfo().getJxmc());
            if (ZsyjhxxShBean.getInfo().getLb().equals("C")){
                blfh_layout.setVisibility(View.GONE);
            }else {
                blfh_layout.setVisibility(View.VISIBLE);
                blfh.setText(ZsyjhxxShBean.getInfo().getFhcsmc());
            }

            sgdw.setText(ZsyjhxxShBean.getInfo().getSgdwmc()); //施工单位名称
            sgdwfzr.setText(ZsyjhxxShBean.getInfo().getSgdwfzr());
            jldw.setText(ZsyjhxxShBean.getInfo().getJldw());
            jldwfzr.setText(ZsyjhxxShBean.getInfo().getJldwfzr());
            jsdw.setText(ZsyjhxxShBean.getInfo().getJsdwmc()); //建设单位名称
            cwzd.setText(ZsyjhxxShBean.getInfo().getCwzd());
            sbgldw.setText(ZsyjhxxShBean.getInfo().getSbgldw());
            qtdw.setText(ZsyjhxxShBean.getInfo().getQtdw());
            shcs.setText(ZsyjhxxShBean.getInfo().getShcsmc()); //审核处室名称
            xmzgbm.setText(ZsyjhxxShBean.getInfo().getSpcsmc()); //审批处室名称
        }


    }

    @Override
    protected void InitListen() {

        tv_cancel.setOnClickListener(this);
        leftTextView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //返回
            case R.id.leftTextView:
                finish();
                break;
            case R.id.tv_cancel:
                finish();
                break;
        }
    }
}
